package cn.jbolt.index;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.OutputStream;
import java.util.HashMap;
import java.util.Map;

import org.eclipse.jetty.client.api.Request;

import com.itextpdf.text.DocumentException;
import com.jfinal.core.Controller;

import cn.jbolt.common.model.Bqdyjl;
import cn.jbolt.common.service.Pdf315AService;
import cn.jbolt.common.service.PdfService;
import cn.jbolt.common.service.Qr315AService;
import cn.jbolt.common.service.QrService;

/**
 * IndexController 指向系统访问首页
 * 
 * @author jbolt.cn
 * @email 909854136@qq.com
 * @date 2018年11月4日 下午9:02:52
 */
public class IndexController extends Controller {

	/**
	 * 首页Action
	 */
	public void index() {
		render("index.html");
	}

	public void printXly() throws IOException, DocumentException {

//		PdfService.createQrCodePdf(20);
		Bqdyjl bqdyjl = getModel(Bqdyjl.class, "Bqdyjl");
		String name = getPara("projectName");
		if (name.equals("NLFL")) {
			QrService qrService = new QrService();
			String[] codeArr = qrService.createDataMatrix(bqdyjl.get("wlh"), bqdyjl.get("sl"), bqdyjl.get("zxsj"),
					bqdyjl.get("zdsj"));
			PdfService pdfService = new PdfService();
			pdfService.createQrCodePdf(codeArr, bqdyjl.get("wlh"));
			File file = new File("C:/download/barpdf/pdf/" + codeArr[1] + ".pdf");
			renderFile(file);
		} else if (name.equals("315A")) {
			String projectType = getPara("projectType");
			Qr315AService qr315AService = new Qr315AService();
			String[] codeArr = qr315AService.createDataMatrix(bqdyjl.get("wlh"), bqdyjl.get("sl"), bqdyjl.get("zxsj"),
					bqdyjl.get("zdsj"));
			Pdf315AService pdf315aService = new Pdf315AService();
			pdf315aService.createQrCodePdf(codeArr, bqdyjl.get("wlh"),projectType);
			File file = new File("C:/download/barpdf/pdf/" + codeArr[1] + ".pdf");
			renderFile(file);
		}

	}

}